﻿using System;
using System.Net;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DXTools.UI.Modules.ODataQueryDesigner.Model
{
    /// <summary>
    /// A small class for managing exceptions.  Subscribe to the
    /// OnMessageAdded handler for actions when messages are added.
    /// </summary>
    public class ControlledExceptionMessages
    {
        private List<string> _exceptionMessages;

        public ControlledExceptionMessages()
        {
            _exceptionMessages = new List<string>();
        }

        /// <summary>
        /// Fires when the message collection changes.
        /// </summary>
        public EventHandler OnMessageAdded;

        public ObservableCollection<string> ExceptionMessages
        {
            get { return new ObservableCollection<string>(_exceptionMessages); }
        }

        public void Add(string message)
        {
            _exceptionMessages.Add(message);
            OnMessageAdded(this, null);
        }

        public void Clear()
        {
            _exceptionMessages.Clear();
            OnMessageAdded(this, null);
        }
    }

}
